#作业一、用类封装一个MyMath类, 实现加, 减, 乘, 除, 幂, 开方


class MyMath:
    def add(self, a, b):
        return a + b

    def sub(self, a, b):
        return a - b

    def mul(self, a, b):
        return a * b

    def div(self,a, b):
        return a / b

    def power(self, a, b):
        return a ** b

    def sqrt(self, a):
        return  a ** (1/2)

aa = MyMath()
print(aa.add(3, 2))

bb = MyMath()
print(bb.sub(3, 2))

cc = MyMath()
print(cc.mul(3, 2))

dd = MyMath()
print(dd.div(3, 2))

ee = MyMath()
print(ee.power(3, 2))

ff = MyMath()
print(ff.sqrt(9))

#作业二、按自己的想法, 将身边的事物抽象出一个类, 并创建多个实例

class Clothes(object):
    def __init__(self, price, size, color):
        self.price = price
        self.size = size
        self.color = color

coat = Clothes(188, 'M', "blue")
shoes = Clothes(99, 'S', "black")
pants = Clothes(88, 'S', "blue")

print(coat.price, coat.size, coat.color)
print(shoes.price, shoes.size, shoes.color)
print(pants.price, pants.size, pants.color)


#作业三、创建多个继承作业2父类的子类

class CoatClothes(Clothes):
    def __init__(self):
        print("外套是衣服的一种")

class ShoesClothes(Clothes):
    def __init__(self):
        print("鞋是衣服的一种")

class PantsClothes(Clothes):
    def __init__(self):
        print(("裤子是衣服的一种"))

coat = CoatClothes()
shoes = ShoesClothes()
pants = PantsClothes()


